<?php
include_once '../tools/common.php';
include_once '../tools/DbTools.php';
$is_login = getLoginStatus();
if(!$is_login){
    echo '尚未登入，<a href="../manage/adminloginUi.php">请登入</a>';
    die;
}else{
    $add_Code=$_POST['add_Code'];
    $add_Name=$_POST['add_Name'];
    $add_Pwd=$_POST['add_Pwd'];
    $newUrl='';
    DbTools::InitDb();
    $sql="SELECT * from accountinfo WHERE 
            AccountCode='$add_Code' and RealName='$add_Name'";
     $result=DbTools::select($sql);
    DbTools::close();
    if (empty($result)){
        echo '你未开户<a href="theopenbank.php">前去开户</a>';
        echo '<br />';
        echo '<a href="theopencard.php">返回上一层</a>';
        die;
    }
     $rand = "6225098".rand(100000,999999);

    $AccountId =$result[0]['AccountId'];
    DbTools::InitDb();
    $sql="INSERT into bankcard(CardNo,AccountId,CardPwd,CardMoney,CardState,CardTime)
 VALUES ('$rand',$AccountId,$add_Pwd,0,0,NOW())";
    $result=DbTools::noSelect($sql);
    DbTools::close();
    if ($result['status']){
        echo '开卡成功<a href="../manage/adminInfo.php">返回管理员中心</a>';
    }else{
        echo '开卡失败'.$result['message'].'<a href="../manage/adminInfo.php">返回管理员中心</a>';
    }
}
?>

